package io.gitee.zhangbinhub.admin.oauth.conf

import io.gitee.zhangbinhub.acp.boot.base.BaseApiConfiguration
import io.gitee.zhangbinhub.admin.common.api.CommonPath
import io.gitee.zhangbinhub.admin.common.api.OauthApi
import io.swagger.v3.oas.models.OpenAPI
import org.springdoc.core.models.GroupedOpenApi
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Value
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

/**
 * @author zhang by 27/12/2018
 * @since JDK 11
 */
@Configuration(proxyBeanMethods = false)
class CustomerApiConfiguration @Autowired
constructor(
    @Value("\${info.version}")
    version: String?,
) : BaseApiConfiguration(version) {
    @Bean
    fun createRestApi(): OpenAPI = buildApiInfo(
        "Oauth Server API",
        "Oauth Server API",
        "ZhangBin",
        "https://gitee.com/zhangbinhub",
        "zhangbin1010@qq.com"
    )

    @Bean
    fun gatewayApi(): GroupedOpenApi = GroupedOpenApi.builder()
        .group("网关接口").pathsToMatch("${OauthApi.basePath}/**")
        .build()

    @Bean
    fun innerApi(): GroupedOpenApi = GroupedOpenApi.builder()
        .group("内部接口").pathsToMatch("${CommonPath.innerBasePath}/**")
        .build()

    @Bean
    fun openInnerApi(): GroupedOpenApi = GroupedOpenApi.builder()
        .group("内部开放接口").pathsToMatch("${CommonPath.openInnerBasePath}/**")
        .build()
}
